package com.suncam.suncam2;

import com.suncam.suncam2.common.result.ResponseEnum;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author LZM
 * @version 1.0
 * @Date 2022/1/14
 * @Description 自定义异常
 */
@Data
@NoArgsConstructor
public class BusinessException extends RuntimeException {

    /**错误码*/
    private Integer code;

    /**错误消息*/
    private String msg;

    /**
     * 功能：
     * @param msg 错误消息
     * @return
     * @author lzm
     * @date 2021/12/22 15:59
     */
    public BusinessException(String msg) {
        this.msg = msg;
    }

    /**
     * 功能：
     * @param msg 错误消息
     * @param code 错误码
     * @author lzm
     * @date 2021/12/22 15:59
     */
    public BusinessException(String msg,Integer code) {
        this.msg = msg;
        this.code = code;
    }

    /**
     * 功能：
     * @param msg 错误消息
     * @param code 错误码
     * @param cause 异常信息
     * @author lzm
     * @date 2021/12/22 15:59
     */
    public BusinessException(String msg,Integer code,Throwable cause) {
        super(cause);
        this.msg = msg;
        this.code = code;
    }

    /**
     * 功能：构造器
     * @param responseEnum 接受枚举类型
     * @author lzm
     * @date 2021/12/22 16:00
     */
    public BusinessException(ResponseEnum responseEnum) {
        this.msg = responseEnum.getMsg();
        this.code = responseEnum.getCode();

    }

    /**
     * 功能：构造器
     * @param responseEnum 接受枚举类型
     * @author lzm
     * @date 2021/12/22 16:00
     */
    public BusinessException(ResponseEnum responseEnum,Throwable cause) {
        super(cause);
        this.msg = responseEnum.getMsg();
        this.code = responseEnum.getCode();

    }



}

